package com.dance.webflux.controller;

import com.dance.webflux.entity.User;
import com.dance.webflux.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/getUserById/{id}")
    public Mono<User> getUserById(@PathVariable Integer id){
        return userService.getUserById(id);
    }

    @GetMapping("/getAllUser")
    public Flux<User> getAllUser(){
        return userService.getAllUser();
    }

    @PostMapping("/saveUserInfo")
    public Mono<Void> saveUserInfo(@RequestBody User user){
        return userService.saveUserInfo(Mono.just(user));
    }

}
